import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { UiService } from '../../ui.service';
import { GB } from '../../../environments/environment';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
import { I18nService } from '../../core/i18n/i18n.service';
import { ActionSheetConfig, SkinType, ActionSheetComponent, ActionSheetService, RatingConfig, PickerService, DatePickerComponent } from 'ngx-weui';
import { MessageService } from './../../core/message.service';
import { InfiniteLoaderComponent, InfiniteLoaderConfig } from 'ngx-weui/infiniteloader';
import { ApiService } from 'src/app/core/api';
import { ActivatedRoute, Router } from '@angular/router';
import { FormBuilder, Validators, FormGroup } from '@angular/forms';
import { StorageService } from 'src/app/core/sotrage/storage.service';

@Component({
  templateUrl: './index.component.html',
  styleUrls: ['./index.component.less'],
  encapsulation: ViewEncapsulation.None,
})
export class OrderComponent implements OnInit {
  @ViewChild(InfiniteLoaderComponent, { static: true }) il;

  restartBtn = false;
  pageData ={
    pageNo:1,
    pages:1
  }
  payList=[
    {
        "id": 1,
        "varId": "O1234567891234567891",
        "amount": 10.00000000,
        "balance": 20.00000000,
        "type": "ORDER", //# RECHARGE充值, ORDER订单
        "status":"PENDING",
// PENDING,
// COMPLETED,
// FAILED,
// CANCELED,
// REFUNDED,
// RECHARGE_WAITING,
// RECHARGE_EXPIRED,
// RECHARGE_FAILED,
// RECHARGE_SUCCESS
        "title": null,
        "name": null,
        "createTime": "2020-02-21 18:31:19"
    }
]
  constructor(
    private api: ApiService,
    private sto: StorageService,
    private route: ActivatedRoute,
    private router: Router,
    private fb: FormBuilder,
    private srv: PickerService,

  ) {
  }
  onLoadMore(comp: InfiniteLoaderComponent) {
		// console.log('加载了。。。')
		this.restartBtn = false;
		comp.resolveLoading();
		if(this.pageData['pageNo'] < this.pageData['pages']){
			this.pageData['pageNo']++;
			this.getList();
		}
  }
  infiniteLoaderConfig:InfiniteLoaderConfig = {
		height:'92vh'
	};
  ngOnInit() {
    this.getList()
  };

  getList() {
    this.api.post('用户资金流记录列表',this.pageData).then((e: any) => {
      this.payList = e['data']['list'];
    });
  }

}
